package com.android.djlmapp.activity.home.web.base;

import android.app.Activity;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.android.djlmapp.token.GetUrlStr;

import static com.android.djlmapp.activity.home.web.base.BaseWebActivity.TOKEN_DEAD_URL;

/**
 * @Author wangziheng
 * @ProjectName djlm
 * @ClassName BaseWebViewClient
 * @package com.android.djlmapp.activity.home.web.base
 * @data 2019/1/11 13:44
 * @Describe
 * @Change
 */
public class BaseWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
        return super.shouldOverrideUrlLoading(view, request);
    }

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url.contains(TOKEN_DEAD_URL)) {
            if(view != null && view.getContext() != null){
                GetUrlStr.getStrUrl((Activity)view.getContext());
            }
            return true;
        }
        return super.shouldOverrideUrlLoading(view, url);
    }
}
